package com.formatos;

import java.io.File;
import java.io.IOException;

import javax.servlet.http.HttpServletResponse;

import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExporter;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.export.JRXlsExporter;
import net.sf.jasperreports.engine.export.JRXlsExporterParameter;

public class XLSReport implements Formato {


	public File escribirReporte(JasperPrint jasperPrint, HttpServletResponse response) throws JRException, IOException {
		JRExporter jRExporter = new JRXlsExporter();
		response.setContentType("application/vnd.ms-excel");
		jRExporter.setParameter(JRXlsExporterParameter.IS_ONE_PAGE_PER_SHEET, Boolean.TRUE);
		jRExporter.setParameter(JRXlsExporterParameter.IS_WHITE_PAGE_BACKGROUND, Boolean.FALSE);
		jRExporter.setParameter(JRXlsExporterParameter.IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS, Boolean.TRUE);
		jRExporter.setParameter(JRXlsExporterParameter.IS_IGNORE_GRAPHICS, Boolean.TRUE);
		jRExporter.setParameter(JRXlsExporterParameter.JASPER_PRINT, jasperPrint);
//		OutputStream output = response.getOutputStream();
//		jRExporter.setParameter(JRXlsExporterParameter.OUTPUT_STREAM, output);
//		jRExporter.exportReport();
//		output.close();
		return Util.export(jRExporter, "xls");
	}

	public Object clone() throws CloneNotSupportedException {
		return new XLSReport();
	}
}
